package com.ce.server.controller;


import com.ce.server.common.RespBean;
import com.ce.server.common.RespPageBean;
import com.ce.server.service.IOperlogService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 郑爽
 * @since 2021-11-28
 */
@RestController
@RequestMapping("/system/log")
public class OperlogController {

  @Autowired
  private IOperlogService operlogService;


  @ApiOperation(value = "分页查询日志")
  @GetMapping("/")
  public RespPageBean getRecordsByPage(@RequestParam(defaultValue = "1") Integer currentPage,
                                       @RequestParam(defaultValue = "10") Integer size) {
    return operlogService.getRecordByPage(currentPage, size);

  }

  @ApiOperation(value = "测试")
  @GetMapping("/test")
  public RespBean getPrincipal(Principal principal) {
    return RespBean.success("测试成功！", principal.getName());
  }
}
